package com.shanshui.test;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

public class RecyclerViewActivity extends AppCompatActivity {
    private MenuAdapter mMenuAdapter;
    private List<MenuBean> mMenuBeans;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_view);
        mMenuBeans = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            MenuBean menuBean = new MenuBean();
            menuBean.id = i;
            menuBean.name = "ssasd" + i;
            mMenuBeans.add(menuBean);
        }
        mMenuAdapter = new MenuAdapter(mMenuBeans);
        RecyclerView recyclerView = findViewById(R.id.recyclerview);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setAdapter(mMenuAdapter);
    }
}